/* wehhttpd
* Copyright (c) 2008 Jeffery Myers
*
* This package is free software;  you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include "httpd.h"

size_t WeeHTTPReply::addBody ( const char* data, size_t size )
{
  if (!bodyData)
  {
    bodyData = (char*)malloc(size);
    memcpy(bodyData,data,size);
    bodySize = size;
  }
  else
  {
    char *t = (char*)malloc(bodySize+size);
    memcpy(t,bodyData,bodySize);
    memcpy(t+bodySize,data,size);
    bodySize += size;
    free(bodyData);
    bodyData = t;
  }

  return bodySize;
}
size_t WeeHTTPReply::getBodySize ( void )
{
  if (bodyData)
    return bodySize;
  else return body.size();
}

const char * WeeHTTPReply::getBody ( void )
{
  if (bodyData)
    return bodyData;
  else
    return body.c_str();
}


// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8
